object DoWhileDemo extends App {
  val maxRenewals = 2
  var renewCount = 0
  var wantToRenew = false

  do {
    wantToRenew = if (renewCount == 0) true else scala.util.Random.nextBoolean()

    if (wantToRenew && renewCount < maxRenewals) {
      renewCount += 1
      println(s"续借成功！当前续借次数：$renewCount/$maxRenewals")
    } else if (renewCount >= maxRenewals) {
      println(s"已达到最大续借次数（$maxRenewals 次），无法继续续借")
      wantToRenew = false
    } else {
      println("用户选择不续借")
    }
  } while (wantToRenew && renewCount < maxRenewals)
  println(s"\n续借流程结束，共续借 $renewCount 次")
}
//第十周【动手练习2】：实现图书续借流程